import {get, post} from '../../utils/request'

const actions={
    // 查询所有咨询分类信息
    findAllConsult(context,list){
        // console.log(context,"11");
        // console.log(list);
        get('/category/findAll',list).then(res=>{
            console.log(res);
            if(res.status===200){
                let response=res.data
                context.commit('SET_CATEGORYS',response)
            }
        })
    },
    // 保存或更新资讯信息
    saveConsult(context,list){
        let response= post('/category/saveOrUpdate',list);
        return response
    },
    // 通过id删除资讯信息
    deleteConsult(context,list){
        let response= get('/category/deleteById',list)
        return response;
    }
}

const mutations={
    SET_CATEGORYS(state,response){
        state.categorys=response
    }
}
const state={
    categorys:[]
}

export default {
    namespaced: true,
    actions,
    mutations,
    state
}